<!DOCTYPE html>
<html lang="en">
<?php
include 'proses/konek.php';
session_start();
if(!isset($_SESSION['admin']))
   {   
  ?><script language="javascript">alert('anda blm login');
document.location='index.html'</script><?php 
}
else
{
$username = $_SESSION['admin'];
}
?>
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>HOME PAGE</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="css/plugins/metisMenu/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/sb-admin-2.css" rel="stylesheet">
    
    <!-- Custom Fonts -->
    <link href="font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="../plugin/tinymce/tinymce.min.js"></script>

   

</head>

<body>

    <div id="wrapper">

        <!-- Navigation -->
        <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="dashboard.php">Admin</a>
            </div>
            
            <!-- /.navbar-top-links -->

            <?php
            include 'proses/menustatic.php';
            $menustatic = new menustatic;
            $menustatic->menus();
             ?>
            <!-- /.navbar-static-side -->
        </nav>

        <!-- Page Content -->
        <?php if(!isset($_GET['update']))
        {
        ?>
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        
                        <script>
                    tinymce.init({
                        selector: "textarea#editor",
                        theme: "modern",
                        width: 700,
                        height: 300,
                        plugins: [
                             "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
                             "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                             "save table contextmenu directionality emoticons template paste textcolor jbimages responsivefilemanager"
                       ],
                       content_css: "css/content.css",
                       toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage | forecolor backcolor emoticons responsivefilemanager", 
                       style_formats: [
                            {title: 'Bold text', inline: 'b'},
                            {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
                            {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
                            {title: 'Example 1', inline: 'span', classes: 'example1'},
                            {title: 'Example 2', inline: 'span', classes: 'example2'},
                            {title: 'Table styles'},
                            {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
                        ],

                    external_filemanager_path:"/plugin/filemanager/",
   filemanager_title:"Responsive Filemanager" ,
   external_plugins: { "filemanager" : "/plugin/filemanager/plugin.min.js"}
                     }); 
                    </script>
                    <h3>POSTING</h3>
                <div class="">
                
                
                    <form class="form-horizontal"  action="proses/save.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">Judul Posting</label>
                            <div class="col-sm-8">
                                <input class="form-control" type="text" name="judul" placeholder="Judul Postingan" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">Image</label>
                            <div class="col-sm-8">
                                <input class="form-control" type="text" id="image" name="image" placeholder="Image" required>
                                <a href="javascript:open_popup('../plugin/filemanager/dialog.php?type=1&popup=1&field_id=image')" class="btn iframe-btn btn-success" type="button" name="select1">select</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">Isi Postingan</label>
                            <div class="col-sm-10">
                                <textarea id="editor" name="area"></textarea>
                            </div>
                        </div>
    
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button class="btn btn-primary" type="submit" name="save" id="save">Publish</button>
                            </div>
                        </div>
                        </form>
                         
                </div>

                    </div>
                    <!-- /.col-lg-12 -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->
        </div>
        <?php
                    }
                    else
                    {
                        $update=$_GET['update'];
                        $sql=mysql_query("SELECT * FROM posting where idpost=$update");
                        $item=mysql_fetch_assoc($sql);
                ?>
                <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        
                        <script>
                    tinymce.init({
                        selector: "textarea#editor",
                        theme: "modern",
                        width: 700,
                        height: 300,
                        plugins: [
                             "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
                             "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                             "save table contextmenu directionality emoticons template paste textcolor jbimages responsivefilemanager"
                       ],
                       content_css: "css/content.css",
                       toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage | forecolor backcolor emoticons responsivefilemanager", 
                       style_formats: [
                            {title: 'Bold text', inline: 'b'},
                            {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
                            {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
                            {title: 'Example 1', inline: 'span', classes: 'example1'},
                            {title: 'Example 2', inline: 'span', classes: 'example2'},
                            {title: 'Table styles'},
                            {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
                        ],

                    external_filemanager_path:"/plugin/filemanager/",
   filemanager_title:"Responsive Filemanager" ,
   external_plugins: { "filemanager" : "/plugin/filemanager/plugin.min.js"}
                     }); 
                    </script>
                    <h3>POSTING</h3>
                <div class="">
                
                
                    <form class="form-horizontal"  action="proses/updateposting.php?id=<?php echo $item['idpost']?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">Judul Posting</label>
                            <div class="col-sm-9">
                                <input class="form-control" type="text" name="judul" placeholder="Judul Postingan" value="<?php echo $item['judul']?>" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">Isi Postingan</label>
                            <div class="col-sm-10">
                                <textarea id="editor" name="area" ><?php echo $item['isi']?></textarea>
                            </div>
                        </div>
    
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button class="btn btn-primary" type="submit" name="save" id="save">Publish</button>
                            </div>
                        </div>
                        </form>
                         
                </div>

                    </div>
                    <!-- /.col-lg-12 -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->
        </div>
                <?php 

                }   
                ?>
        <!-- /#page-wrapper -->

    </div>
    
    <!-- jQuery -->
    <script src="js/jquery-1.4.3.min.js"></script>
     <!-- /#fancybox -->
    <script src="js/jquery.fancybox-1.3.4.pack.js"></script>
    <link href="css/style.css" rel="stylesheet">
    <link href="css/jquery.fancybox-1.3.4.css" rel="stylesheet">
    <!--<script type="text/javascript">
    $('.iframe-btn').fancybox({
    
    'width'     : '700',
    'height'    : '800',
    'type'      : 'iframe',
    'autoScale' : 'true'
    });
    </script>-->
    <script type="text/javascript">
            function open_popup(url) {
                var w = 880;
                var h = 600;
                var l = Math.floor((screen.width-w)/2);
                var t = Math.floor((screen.height-h)/2);
                var win = window.open(url, 'ResponsiveFilemanager', "scrollbars=1,width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
            }
        </script>
    <!-- jquery -->
    <script src="js/jquery.js"></script>
    <!-- Custom Theme JavaScript -->
    <script src="js/sb-admin-2.js"></script>
    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>
    <!-- Metis Menu Plugin JavaScript -->
    <script src="js/plugins/metisMenu/metisMenu.min.js"></script>
</body>

</html>
